/**
 * Created by Administrator on 2016/12/1 0001.
 */
var app = angular.module("myApp",["ng",'ngRoute']);
app.config(["$routeProvider",function($routeProvider){
    $routeProvider.when('/account',{
        templateUrl:"account/account.html"
    }).when('/account-add',{
        templateUrl:"form/account-add.html"
    }).when('/account-update',{
        templateUrl:"form/account-update.html"
    }).when('/account-updatePwd',{
        templateUrl:"form/account-updatePwd.html"
    }).when('/account-character',{
        templateUrl:"form/account-character.html"
    }).when('/account-character-add',{
        templateUrl:"form/account-character-add.html"
    }).when('/account-character-allot',{
        templateUrl:"form/account-character-allot.html"
    }).when('/customer-account',{
        templateUrl:"form/customer-account.html"
    }).when('/character',{
        templateUrl:"character/character.html"
    }).when('/character-add',{
        templateUrl:"form/character-add.html"
    }).when('/character-update',{
        templateUrl:"form/character-update.html"
    }).when('/character-allot',{
        templateUrl:"form/character-allot.html"
    }).when('/character-allotUser',{
        templateUrl:"form/character-allotUser.html"
    }).when('/menuManager',{
        templateUrl:"menuManager/menuManager.html"
    }).when('/menuManager-add',{
        templateUrl:"form/menuManager-add.html"
    }).when('/menuManager-update',{
        templateUrl:"form/menuManager-update.html"
    }).when('/menuManager-detail',{
        templateUrl:"form/menuManager-detail.html"
    }).when('/privilege',{
        templateUrl:"privilege/privilege.html"
    }).when('/privilege-add',{
        templateUrl:"form/privilege-add.html"
    }).when('/privilege-update',{
        templateUrl:"form/privilege-update.html"
    }).when('/operation',{
        templateUrl:"operation/operation.html"
    }).when('/operation-add',{
        templateUrl:"form/operation-add.html"
    }).when('/operation-update',{
        templateUrl:"form/operation-update.html"
    }).when('/resource',{
        templateUrl:"resource/resource.html"
    }).when('/resource-add',{
        templateUrl:"form/resource-add.html"
    }).when('/resource-update',{
        templateUrl:"form/resource-update.html"
    }).when('/theme',{
        templateUrl:"theme/theme.html"
    }).when('/theme-add',{
        templateUrl:"form/theme-add.html"
    }).when('/theme-update',{
        templateUrl:"form/theme-update.html"
    }).when('/portal',{
        templateUrl:"portal/portal.html"
    }).when('/portal-add',{
        templateUrl:"form/portal-add.html"
    }).when('/portal-update',{
        templateUrl:"form/portal-update.html"
    }).when('/customer',{
        templateUrl:"customer/customer.html"
    }).when('/customer-add',{
        templateUrl:"form/customer-add.html"
    }).when('/customer-update',{
        templateUrl:"form/customer-update.html"
    }).when('/customer-allotAccount',{
        templateUrl:"form/customer-allotAccount.html"
    }).when('/customer-batchAllotAccount',{
        templateUrl:"form/customer-batchAllotAccount.html"
    }).when('/adminDivision',{
        templateUrl:"adminDivision/adminDivision.html"
    }).when('/adminDivision-add',{
        templateUrl:"form/adminDivision-add.html"
    }).when('/adminDivision-update',{
        templateUrl:"form/adminDivision-update.html"
    }).when('/government',{
        templateUrl:"government/government.html"
    }).when('/government-add',{
        templateUrl:"form/government-add.html"
    }).when('/government-update',{
        templateUrl:"form/government-update.html"
    }).when('/company',{
        templateUrl:"company/company.html"
    }).when('/company-add',{
        templateUrl:"form/company-add.html"
    }).when('/company-update',{
        templateUrl:"form/company-update.html"
    }).when('/section',{
        templateUrl:"section/section.html"
    }).when('/section-add',{
        templateUrl:"form/section-add.html"
    }).when('/section-update',{
        templateUrl:"form/section-update.html"
    }).when('/site',{
        templateUrl:"site/site.html"
    }).when('/site-add',{
        templateUrl:"form/site-add.html"
    }).when('/site-update',{
        templateUrl:"form/site-update.html"
    }).when('/siteType',{
        templateUrl:"siteType/siteType.html"
    }).when('/siteType-add',{
        templateUrl:"form/siteType-add.html"
    }).when('/siteType-update',{
        templateUrl:"form/siteType-update.html"
    }).otherwise({redirectTo:"/account"});
}]);
app.controller("parentCtrl",['$scope','$location',function($scope,$location){
    $("a").click(function(e){
        e.preventDefault();
        $(this).css("text-decoration","none");
    });
    $scope.jump = function(url){
        $location.path(url);
    };
    $scope.back = function(){
        history.back(-1);
    };
//    退出系统
    $(".quit").click(function(){
        $(".quitSystem").show();
    });
    $scope.quitSystem = function(){
        $(".quitSystem").hide();
    };
    $scope.cancelQuitSystem = function(){
        $(".quitSystem").hide();
    };
//    修改密码
    $(".pwd").click(function(){
        $(".updatePwd").show();
    });
    $scope.updatePwd = function(){
        $(".updatePwd").hide();
    };
    $scope.cancelUpdatePwd = function(){
        $(".updatePwd").hide();
    };
}]);
//侧边栏点击事件
$(".one-open-tree").click(function(){
    if($(".one-sidebar-menu  .one-treeview-menu").css("display")=="none"){
        $('.one-sidebar-menu  .one-treeview-menu-open').removeClass("active");
        $('.one-sidebar-menu  .one-treeview-menu li').removeClass("active");
        $('.one-sidebar-menu  .one-treeview-menu li a').removeClass("active");
    }
    if($(this).siblings(".one-treeview-menu").css("display")=="block"){
        $(this).siblings(".one-treeview-menu").slideUp(300).siblings(".one-treeview-menu-open").removeClass("active");
    }else{
        $(this).siblings(".one-treeview-menu").slideDown(300).siblings(".one-treeview-menu-open").addClass("active");
    }
    $(this).parent().siblings().find(".one-treeview-menu").slideUp(300).siblings(".one-treeview-menu-open").removeClass("active");
});
$(".one-treeview-menu").on("click","li",function(){
   $(this).addClass("active").siblings(".active").removeClass("active");
    $(this).find("a").addClass("active").parent().siblings().find(".active").removeClass("active");
});
$(".one-modal").click(function(e){
    var target = $(e.target);
    if(target.closest(".one-register-box-body").length == 0){
        $(".one-modal").hide();
    }
});
//点击顶部导航中的按钮
$(".one-sidebar-toggle").click(function(){
    if($(".one-sidebar-menu li:not(:first-child)>a>span").css("display")=="none") {
        $(".one-sidebar").css("width","230px");
        $(".one-content-wrapper").css("marginLeft","230px");
        $(".one-sidebar-menu li .one-treeview-menu>.active").parent().show(100);
        $(".one-sidebar-menu>li").removeClass("open-tree-height");
        $(".one-sidebar-menu li>.one-treeview-menu").removeClass("hideTreeView");
        $(".one-sidebar-menu li>a>span").show();
        $(".one-sidebar-menu li>img").show();
    }else{
        $(".one-sidebar").css("width","60px");
        $(".one-content-wrapper").css("marginLeft","60px");
        $(".fixed-table-header>.table").css("width","100%");
        $(".one-sidebar-menu li:not(:first-child)>a>span").hide();
        $(".one-sidebar-menu li>img").hide();
        $(".one-sidebar-menu>li").addClass("open-tree-height");
        $(".one-sidebar-menu li>.one-treeview-menu").hide().addClass("hideTreeView");
    }
});